package com.example.demo.common;

import com.example.demo.entity.UserInfo;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: DELL
 * Date: 2023-06-07
 * Time: 11:55
 */

public class GetUserSessionTools {

    public static UserInfo getLoginUser(HttpServletRequest request) {

        HttpSession session = request.getSession(false);

        if (session != null && session.getAttribute(ApplicationVariable.SESSION_USERINFO_KEY) != null) {
            return (UserInfo) session.getAttribute(ApplicationVariable.SESSION_USERINFO_KEY);

        }
        return null;
    }
}
